using System.Collections.Generic;
using System.Threading.Tasks;
using Grpc.Core;
using static Permissions.PermissionsService;

namespace Permissions.Services;

public class PermissionsServiceV1 : PermissionsServiceBase
{
    public PermissionsServiceV1()
    {
    }

    public override Task<IsUserAllowedResponse> IsUserAllowed(IsUserAllowedRequest request, ServerCallContext context)
    {
        var response = new IsUserAllowedResponse { IsAllowed = false };
        if ("test-permission"==request.Permission)
        {
            response.IsAllowed = true;
        }
        return Task.FromResult(response);
    }

    public override Task<UserPermissionsResponse> GetUserPermissions(UserPermissionsRequest request, ServerCallContext context)
    {
        var response = new UserPermissionsResponse();
        response.Permissions.Add("Permission1");

        return Task.FromResult(response);
    }
}
